var zukeKongjian=({
	loginout : function(){
		$.ajax({
			type : "POST",
			dataType : 'json',
			url : "../login/ljLogout.do",
			data : {
			},
			success : function(data) {
				console.log(data);
				if(data.resultCode==0){
					$$.toast("退出成功");
					document.cookie="phone="+null;
					window.location.href = "../jsp/login.html";
				}
			}
		});
	},
	getUserInfo : function (){
		$.ajax({
			type : "POST",
			dataType : 'json',
			url : "../user/isLogin.do",
			data : {
				"phone" : zukeKongjian.getCookie("phone")
			},
			success : function(data) {
				if(data.success){
					var flag="";
					if(data.user.flag==0) flag="租客";
					if(data.user.flag==1) flag="房东";
					if(data.user.flag==2) flag="管家";
					if (data.user.nickName!=null) 
					{$("#name").html("");
					$("#name").text(data.user.nickName+"("+flag+")");}
					if (data.user.headImg!=null)
					{$("#headimg").attr("src",data.user.headImg.split(",")[0]);}
					if(data.user!=null){
						$("#loginout").show();
						if(data.user.openId==null){
							$("#auth").show();
						}else{
							$("#auth").hide();
						}
					}else{
						$("#auth").hide();
					}
					
					if(data.user.flag==0){
						$("#myfoot").show();
					}
					if(data.user.flag==1){
						$(".fangdong").show();
					}
				}
			}
		});
		
	},
	getCookie : function (name) 
	{ 
	    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
	 
	    if(arr=document.cookie.match(reg))
	 
	        return unescape(arr[2]); 
	    else 
	        return null; 
	} ,
	toLink : function (txt,tagrt){
		var phone= zukeKongjian.getCookie("phone");
		$.ajax({
			type : "POST",
			dataType : 'json',
			data:{"phone" :phone},
			url : "../user/isLogin.do",
			success : function(data) {
				console.log(data);
				if(data.success){
					 if(data.user.idCard==null){
						 data.msg="您还实名认证，请认证后继续吧";
						 $$.alert(data.msg, function () {
							 window.location.href="./authentication.html?phone="+data.user.phone;
					    });
					 }else{
							var url_="./" + txt;
							var arlArr=url_.split("?");
							if(arlArr.length>1){
								document.location.href = "./" + txt+"&userId="+data.user.userId;
							}else{
								document.location.href = "./" + txt+"?userId="+data.user.userId;
							}
					 }
				}else{
					 $$.alert(data.msg, function () {
				          window.location.href="./login.html?url="+encodeURIComponent(window.location.href);
				     });
				}
			}
		});
		
	},
	tologin : function (){
		window.location.href="../weixinImpl/login.do";
	},
	toLinkNoLogin : function (txt,tagrt){
		document.location.href = "./" + txt;
	}
});
